<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
<title>实现加减乘除</title>  
<script type="text/javascript">  
    function operation(){  
        //第一个数  
        var oneNumber =  parseInt(document.getElementById("one").value);  
        //alert(oneNumber);  
          
        //第二个数  
        var twoNumber =  parseInt(document.getElementById("two").value);  
        //alert(twoNumber);  
          
        //运算符  
        var calculate = document.getElementById("select").value;  
       // alert(calculate);  
          
        //计算结果  
        var result = parseInt(document.getElementById("select").value);  
        
          
        /**  
        *计算符号的判断  
        */  
        switch(calculate)  
        {  
            case'+': result = oneNumber + twoNumber; 
           
                 break;  
              
            case'-': result = oneNumber - twoNumber;  
                 break;  
              
            case'*': result = oneNumber * twoNumber;  
                 break;  
              
            case'/': result = oneNumber / twoNumber;  
                break;  
                  
            default:alert("错误");  
                break;  
        }  
        alert(result);
        document.getElementById("jg").value=result;
    }  
</script>  
</head>  
  
<body>  
   <input type="text" id="one" size="12" style="width:40px; "/>  
    <select id="select">  
       <option value="+">+</option>  
       <option value="-">-</option>  
       <option value="*">*</option>  
       <option value="/">/</option>  
    </select>  
   <input type="text" id="two" size="12" style="width:40px; "/> =  
   <input type="button" id="three" value="?" style="border:none; background-color:#FFFFFF;" onclick="operation();"/>  
   <input type="text" id="jg"/>
</body>  
</html>  